
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>SpringBoot自动装配 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>SpringBoot自动装配 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Spring Boot自动装配机制遵循的核心原则是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Boot自动装配遵循“约定优于配置”的原则。这意味着如果开发者按照一定的约定组织代码和资源文件，Spring Boot就能自动发现、加载和配置这些组件，而无需显式地进行配置。</div>
          </div>
          <div class="card-source">来源: 什么是自动装配</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring Boot是如何利用SPI机制来发现和加载自动配置类的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Boot在启动时会扫描类路径下所有jar包中的`META-INF/spring.factories`文件。该文件是一个标准的Java配置文件，通过键值对声明了需要加载的自动配置类。Spring Boot读取这些声明并加载对应的类，从而实现自动装配。</div>
          </div>
          <div class="card-source">来源: SPI机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Spring Boot中，“Starter依赖”扮演了什么角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Starter是一组预配置的依赖库，用于方便地集成特定功能或库。每个Starter都包含了一组相关的依赖项和自动配置类。开发者只需引入适当的Starter依赖，相关的自动配置就会被自动应用，从而实现功能的快速集成。</div>
          </div>
          <div class="card-source">来源: 工作原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">什么是Spring Boot的“条件化配置”？它通过什么注解实现？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">条件化配置是指Spring Boot根据应用程序的环境、配置和类路径等条件来控制哪些组件应该被自动装配。这种机制主要通过`@Conditional`注解及其派生注解（如@ConditionalOnClass, @ConditionalOnProperty等）来实现，从而达到在不同环境下的灵活配置。</div>
          </div>
          <div class="card-source">来源: 什么是自动装配</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">请列举Spring Boot自动装配机制带来的至少三项主要优势。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">1. 简化配置：根据约定和条件自动配置组件，减少手动配置。 2. 提高开发效率：开发者可以专注于业务逻辑，无需处理繁琐的配置细节。 3. 降低出错率：通过内置规则保证配置正确性，提高系统稳定性。此外还有可移植性和灵活性等优势。</div>
          </div>
          <div class="card-source">来源: 自动装配的优势</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">要实现一个自定义的Spring Boot自动配置，需要完成哪些关键步骤？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要步骤包括：1. 创建一个带有`@Configuration`注解的自动配置类；2. 使用条件注解（如`@ConditionalOnClass`）来限制其生效条件；3. （可选）通过`@ConfigurationProperties`注解读取外部属性以实现灵活配置；4. 在`META-INF/spring.factories`文件中声明该自动配置类的全限定名。</div>
          </div>
          <div class="card-source">来源: 自定义自动装配</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中提到的`@ConditionalOnProperty`注解有什么作用？请结合示例说明。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该注解用于根据配置文件中的特定属性来决定是否创建某个Bean。在示例中，`@ConditionalOnProperty(name = "my.feature.enabled", havingValue = "true")`注解意味着只有当配置文件中`my.feature.enabled`属性的值为`true`时，`myService`这个Bean才会被创建。</div>
          </div>
          <div class="card-source">来源: 条件装配</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">什么是Java的SPI（Service Provider Interface）机制？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">SPI是一种服务提供者接口，它允许开发者定义服务接口，而服务的具体实现由第三方提供。它通过在`META-INF/services`（或Spring Boot中的`META-INF/spring.factories`）目录下的配置文件中指定接口的实现类，来实现接口的动态加载，从而提高了系统的灵活性和可扩展性。</div>
          </div>
          <div class="card-source">来源: SPI机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring Boot的“自动扫描”机制是如何工作的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Boot会自动扫描指定包及其子包，寻找标记了`@Component`及其衍生注解（如@Service, @Repository等）的类，并将它们自动注册为Spring容器中的Bean。这种机制简化了Bean的注册过程，提高了开发效率。</div>
          </div>
          <div class="card-source">来源: 什么是自动装配</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
